<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Link extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->model('link_model');
	}
	
	public function index()
	{
		$data['link_list'] = $this->link_model->index();
		$data['link_new'] = $this->link_model->linkList('new');
		//$this->load->view('header',$data);
		//$this->load->view('link/index');
		//$this->load->view('footer');
		$this->load->view('link/link',$data);
	}
	
	public function add()
	{
		$data = array();
		if ($_POST) {
			$sitename = $this->input->post('sitename');
			$url = $this->input->post('url');
			if (!$sitename || !$url) {
			
			}
			if ($this->link_model->add($sitename, $url)) {
				$data['msg'] = '恭喜^_^ ，您的网址已经收录。';
			} else {
				$data['msg'] = '抱歉%>_<%，网址已经提交过，请不要重复提交。';
			}
		} 
		$this->load->view('link/link_add',$data);
	}
	
}

/* End of file Link.php */
/* Location: ./application/controllers/Link.php */